package com.xiashitech.agent.instrumentation.biz.userinfo.springsecurity.inst;

import com.google.auto.service.AutoService;
import com.xiashitech.agent.rule.usermatch.Register;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static java.util.Arrays.asList;

@AutoService(InstrumentationModule.class)
public class XSAuthenticationInstrumentationModule extends InstrumentationModule {
    public XSAuthenticationInstrumentationModule() {
        super("xs.user-springsecurity");
    }

    @Override
    public List<TypeInstrumentation> typeInstrumentations() {
        return asList(new XSAuthenticationInstrumentation());
    }

    @Override
    public List<String> getAdditionalHelperClassNames() {
        List<String> helperClassNames = new ArrayList();
        helperClassNames.addAll(Arrays.asList(
                "com.xiashitech.agent.instrumentation.biz.userinfo.springsecurity.XSAuthenticationSingletons",
                "com.xiashitech.agent.instrumentation.biz.userinfo.springsecurity.XSAuthenticationAttributesExtractor"
        ));
        helperClassNames.addAll(Register.registUserMatch());
        return helperClassNames;
    }
}
